<?php
/**
 * Description: 事业单位年份地区
 * User: lizengcai
 * Date: 16/12/1
 * Time: 13:00
 */

class GetAreaYear implements iController {

    /**
     * api请求处理主函数
     * @param array $queryArgs 就是$_REQUEST变量
     * @return array api返回结果，必须含response_code
     */
    public function output($queryArgs)
    {
        global $cmsdb;

        $areas = $cmsdb->getResults('SELECT * FROM `original_ztk_area`');

        $years = $cmsdb->getCol('SELECT DISTINCT(`year`) FROM `institution_papers` ORDER BY `year` DESC');

        $areaList = array();
        foreach ($areas as $area) {
            $areaList[] = array(
                'area_id' => intval($area->id),
                'name' => $area->name
            );
        }

        $yearList = array();
        foreach ($years as $year) {
            $yearList[] = intval($year);
        }

        return genOutput(1, array(
            'area' => $areaList,
            'year' => $yearList
        ));
    }

}